/**
 * 眉毛 节点
 */
cc.Class({
    extends: cc.Component,

    properties: {
        //眉毛抖动一次需要时间(秒)
        shakingDuration: 0.25,

        //眉毛上下抖动的距离
        shakingDisatance: 20,

        //点击一次眉毛抖动次数
        shakingTimes: 2
    },

    setShakeAction: function () {
        //向上抖动
        let upShaking = cc.moveBy(this.shakingDuration, cc.v2(0, this.shakingDisatance)).easing(cc.easeCubicActionOut());
        let downShaking = cc.moveBy(this.shakingDuration, cc.v2(0, -this.shakingDisatance)).easing(cc.easeCubicActionOut());

        return cc.repeat(cc.sequence(upShaking, downShaking), this.shakingTimes); //按顺序执行，并且重复两次
    },

    // LIFE-CYCLE CALLBACKS:
    onLoad() {
        //将当前this对象保存一份，因为在回调函数中this将不会指向当前的this
        const _self = this;

        //初始化抖动动作
        this.shakeAction = this.setShakeAction();

        //当该节点加载完成后绑定点击事件
        this.node.on(cc.Node.EventType.TOUCH_END, function (ev) {
            _self.node.runAction(_self.shakeAction);
        })
    },

    onDestroy() {},

    start() {},

    update(dt) {},
});